package jwr.ex5;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class ExVO implements ExService{
	private static final String DRV = "oracle.jdbc.OracleDriver";
	private static final String URL = "jdbc:oracle:thin:@//localhost:1521/xe";
	private static final String USR = "scott";
	private static final String PWD = "TIGER";
	
	private static final String insertSQL ="insert into cdinfo VALUES('a0001','홍길동 1집','오늘 레코드','홍길동',8000)";
	@Override
	public boolean newEx() {
		boolean result = false;
		Connection conn=null;
		PreparedStatement ps = null;
		try {
			Class.forName(DRV);
			conn = DriverManager.getConnection(URL, USR, PWD);
			ps = conn.prepareStatement(insertSQL);
			/*ps.setString(1, "a0001");
			ps.setString(2, "홍길동 1집");
			ps.setString(3, "오늘 레코드");
			ps.setString(4, "홍길동");
			ps.setInt(5, 8000);*/
			int cnt = ps.executeUpdate();
			if (cnt>0) result = true;
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			if(ps!=null) 
				try{ ps.close(); } catch (Exception e) { }
			if(conn!=null)
				try { conn.close();	} catch (Exception e2) { }
		}
		return result;
	}

}
